package com.itheima.mapper;

import com.itheima.pojo.Emp;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface EmpMapper {

//    @Select("select count(*) from emp")
//    long getCounts();
//
//    @Select("select * from emp limit #{index} , #{pageSize}")
//    List<Emp> selectAllEmp(@Param("index") Integer index, @Param("pageSize") Integer pageSize);

    List<Emp> selectAllEmp(@Param("name") String name, @Param("gender") Integer gender,
                           @Param("begin") LocalDate begin, @Param("end") LocalDate end);


    void deleteEmpByIds(@Param("ids") List<Integer> ids);

    //@Insert("insert into emp(id,username,password, name, gender, image, job, entrydate, dept_id, create_time, update_time) values(#{id} , #{username} ,#{password} , #{name} ,#{gender} ,#{image} ,#{job} ,#{entrydate} ,#{deptId} ,#{createTime} ,#{updateTime} )")
    @Insert("insert into emp(username, name, gender, image, job, entrydate, dept_id, create_time, update_time) values" +
            "(#{emp.username}, #{emp.name},#{emp.gender}, #{emp.image},#{emp.job}, #{emp.entrydate},#{emp.deptId}, #{emp.createTime},#{emp.updateTime})")
    void insertEmp(@Param("emp") Emp emp);

    @Select("select * from emp where id = #{id}")
    Emp selectEmpById(@Param("id") Integer id);


    void updateEmpInfo(Emp emp);

    @Select("select * from emp where username = #{username} and password = #{password}")
    Emp login(Emp emp);

    @Delete("delete from emp where dept_id = #{id}")
    void deleteEmpById(Integer id);
}
